Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add new routes and features for ticket and flag management (CRUD api) #15

Merged
merged 18 commits into from
Dec 7, 2023

Conversation

Valimp
Copy link
Collaborator

@Valimp Valimp commented Nov 30, 2023

Docker compose

Add postgres

Models

Add models for posgres tables "flags", "tickets", "moderator_actions"

Flag Creation Endpoint:

Flag Creation Endpoint:

Added a new endpoint (/flags) for creating flags, representing a one-to-one relationship with tickets. This feature allows users to report issues related to a product, providing details such as barcode, type of issue, user ID, device ID, source, confidence, image ID, flavour, reason, and comments.
Flag Retrieval Endpoint:

Flag Retrieval Endpoint:

Implemented a new endpoint (/flags) to retrieve all flags, showcasing the one-to-many relationship between flags and tickets. Users can view a list of reported issues along with their associated details.
Ticket Status Update Endpoint:

Ticket Status Update Endpoint:

Introduced an endpoint (/tickets/{ticket_id}/status) to update the status of a ticket. Users can now change the status of a ticket to either "open" or "closed," representing a soft delete mechanism.

Some other Endpoints

GET all flags or tickets (/flags) / (/tickets)
GET flags or tickets by id (/flags/{id}) / (/tickets/{id})
Hard DELETE flags or tickets by id (/flags/{id}) / (/tickets/{id})

Mention : @raphael0202

app/models.py Outdated Show resolved Hide resolved
@raphael0202
Copy link
Contributor

@Valimp the pre-commit hook is failing, can you update it by using the one from Open prices? https://github.com/openfoodfacts/open-prices/blob/main/.pre-commit-config.yaml
We should just switch python version to 3.11

@Valimp
Copy link
Collaborator Author

Valimp commented Nov 30, 2023

I'm going to fix that thanks

Copy link
Contributor

@raphael0202 raphael0202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! I've added my feedback :)
You should also add integration tests, you can look at open-prices repo to see how it's done!

app/models.py Show resolved Hide resolved
app/models.py Outdated Show resolved Hide resolved
app/models.py Show resolved Hide resolved
.env Outdated Show resolved Hide resolved
app/api.py Outdated Show resolved Hide resolved
app/api.py Outdated Show resolved Hide resolved
app/api.py Outdated Show resolved Hide resolved


# Get all flags (one to many relationship)
@app.get("/flags")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's okay for a first version, but we should quickly add pagination

app/api.py Outdated Show resolved Hide resolved
app/api.py Outdated Show resolved Hide resolved
app/models.py Outdated
)

db = PostgresqlDatabase(
"postgres", user="postgres", password="postgres", host="postgres", port=5432
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use envvar instead of hardcoded values, you can add declare them in config.Settings. Make sure they are defined in docker-compose.yml (in the environment section), otherwise docker doesn't pass the envvar to the container

app/models.py Outdated Show resolved Hide resolved
@raphael0202 raphael0202 merged commit a9c6bf1 into main Dec 7, 2023
3 checks passed
@raphael0202 raphael0202 deleted the first-step branch December 7, 2023 16:21
@github-actions github-actions bot mentioned this pull request Dec 7, 2023
@alexgarel
Copy link
Member

@Valimp you wrote a nice description to this PR, it's a pity it's not in any /docs folder in the project. Here it's lost. Could you put it in some file ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants